package com.itheima.feiqiu;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.Scanner;

/*
给飞秋发点啥
 */
public class SendClient {

    public static void main(String[] args) throws IOException {
        //创建发送端对象
        DatagramSocket ds = new DatagramSocket();
        InetAddress ip = InetAddress.getByName("192.168.101.31");
        //飞秋的端口
        int port = 2425;
        Scanner sc = new Scanner(System.in);
        String s = "1:100:zhaichaojie:teacher_zhai:32: ";
        while (true) {
            String s1 = sc.nextLine();
            String shuju = s + s1;
            //创建数据对象
            DatagramPacket dp = new DatagramPacket(shuju.getBytes("GBK"), shuju.getBytes("GBK").length, ip, port);

            //发送
            ds.send(dp);
            if ("886".equals(s1)) {
                break;
            }
        }

        // 释放资源
        ds.close();

    }
}
